<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>GNU工具链简介（全） - 随风 - 博客频道 - CSDN.NET</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="Mips GNU工具链简介&nbsp;&nbsp;1 . 总括 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本文分三部分来介绍mips的工具链，首先工具链的总括，其次是每个工具链的简介，最后是各工具链的实际应用举例。我们的项目使用的工具链就如图1所示,声明，本文所述的内容实乃GNU工具链的九牛之一毛, 日后会陆续更新。&nbsp;&nbsp;http://blog.csdn.net/dyron">
<script src="6866406_files/getnl" async="" type="text/javascript"></script><script src="6866406_files/ga.js" async="" type="text/javascript"></script><script src="6866406_files/jquery.js" type="text/javascript"></script>
<script src="6866406_files/plugins.js" type="text/javascript"></script>
<script src="6866406_files/common.js" type="text/javascript"></script>
<link rel="Stylesheet" type="text/css" href="6866406_files/style.css">
<link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="http://blog.csdn.net/dyron/rss/list">
<link rel="shortcut icon" href="http://blog.csdn.net/favicon.ico">
<link type="text/css" rel="stylesheet" href="6866406_files/default.css">
</head>
<body>
<script src="6866406_files/pub_topnav_2011.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="6866406_files/navtop_2012.css">
<div class="nav_top_2011">
<p>欢迎<em>fedorayang</em><a href="http://my.csdn.net/my/notifications" class="notice_num" id="header_notice_num">0</a>我的：<a href="http://my.csdn.net/my/letter">收件箱<span id="header_letter_num"></span></a><a href="http://download.csdn.net/my" class="red">资源</a><a href="http://write.blog.csdn.net/" class="red">博客</a><a href="http://my.csdn.net/">空间</a><a href="http://passport.csdn.net/account/profile">设置</a>|<a href="http://passport.csdn.net/help/faq">帮助</a>|<a href="http://passport.csdn.net/account/logout">退出</a></p><ul>
<li><a href="http://www.csdn.net/" target="_blank">CSDN首页</a></li>
<li><a href="http://news.csdn.net/" target="_blank">资讯</a></li>
<li><a href="http://bbs.csdn.net/" target="_blank">论坛</a></li>
<li><a href="http://blog.csdn.net/" target="_blank">博客</a></li>
<li><a href="http://download.csdn.net/" target="_blank">下载</a></li>
<li><a href="http://so.csdn.net/" target="_blank">搜索</a></li>
<li class="more"><h2 id="topnav_btnmore" onclick="showNavMore(this)"><a href="javascript:void(0);">更多</a></h2>
<ul id="topnav_hidlist">
<li><a href="http://cto.csdn.net/" target="_blank">CTO俱乐部</a></li>
<li><a href="http://student.csdn.net/" target="_blank">学生大本营</a></li>
<li><a href="http://edu.csdn.net/" target="_blank">培训充电</a></li>
<li><a href="http://mobile.csdn.net/" target="_blank">移动开发</a></li>
<li><a href="http://sd.csdn.net/" target="_blank">软件研发</a></li>
<li><a href="http://cloud.csdn.net/" target="_blank">云计算</a></li>
<li><a href="http://www.programmer.com.cn/" target="_blank">程序员</a></li>
<li><a href="http://www.iteye.com/" target="_blank">ITeye</a></li>
<li><a href="http://tup.csdn.net/" target="_blank">TUP</a></li>
</ul>
</li>
</ul>
</div>


<div id="container">
<div id="header">
    <div class="header">
        <div id="blog_title">
            <h1>
                <a href="http://blog.csdn.net/dyron">随风</a></h1>
            <h2>无声又无息，留在回忆里！</h2>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>
            <!--<li id="btnHome"><a href="/dyron"><span><img src="http://static.blog.csdn.net/images/ico_home.gif">我的首页</span></a></li>-->
            <li id="btnContents"><a href="http://blog.csdn.net/dyron?viewmode=contents"><span><img src="6866406_files/ico_list.gif">目录视图</span></a></li>
            <li id="btnView"><a href="http://blog.csdn.net/dyron?viewmode=list"><span><img src="6866406_files/ico_summary.gif">摘要视图</span></a></li>
            <li id="btnRss"><a href="http://blog.csdn.net/dyron/rss/list"><span><img src="6866406_files/ico_rss.gif">订阅</span></a></li>
</ul>
    </div>
</div>
<script type="text/javascript">
    var username = "dyron";
    var blog_address = "http://blog.csdn.net/dyron";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = $.cookie("UserName");
</script>
        
<div id="body">
<div id="main">
<div class="main">
<div class="notice"> 


<a href="http://cloud.csdn.net/a/20120620/2806805.html" target="_blank"><font color="red">用开源IaaS构建自己的云——OpenStack征稿启事
</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://adclk.thinkmedia.cn/clk/pid=2000/media=CSDN.CN/place=1Clt1/size=760x90" target="_blank"><font color="blue">不用买彩票，就有408万！</font></a>
<br>
<a href="http://blog.csdn.net/blogdevteam/article/details/7608507" target="_blank"><font color="blue">CSDN博客频道“移动开发之我见”主题征文活动 </font></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://blog.csdn.net/blogdevteam/article/details/7666263" target="_blank"><font color="red"> 2012CSDN网站八大职位急聘</font></a>


</div><script type="text/javascript" src="6866406_files/ad.js"></script>

<div id="article_details" class="details">
    <div class="article_title">
    <span class="ico ico_type_Original"></span>
    <h3>
        <span class="link_title"><a href="http://blog.csdn.net/dyron/article/details/6866406">
        GNU工具链简介（全）
        </a></span>
    </h3>
</div>

        
    <div class="article_manage">
        <span class="link_categories">
        分类：
            <a href="http://blog.csdn.net/dyron/article/category/904105">toolchain</a> 
        </span>
    <span class="link_postdate">2011-10-12 14:51</span>
    <span class="link_view" title="阅读次数">382人阅读</span>
    <span class="link_comments" title="评论次数"><a href="#comments">评论</a>(0)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:collectArticle('GNU工具链简介（全）','6866406');return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="#report" onclick="javascript:report(6866406,2);return false;" title="举报">举报</a></span>
    
</div>

    
<div id="article_content" class="article_content">
    
<div id="detail">
<div align="center"><span style="font-size:24px"><strong><span style="font-family:Calibri">Mips GNU</span>工具链简介</strong></span></div>
<div>&nbsp;</div>
<div><strong>&nbsp;<span style="font-family:Cambria">1 . </span>总括 </strong></div>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>本文分三部分来介绍<span style="font-family:Calibri">mips</span>的工具链，首先工具链的总括，其次是每个工具链的简介，最后是各工具链的实际应用举例。我们的项目使用的工具链就如图<span style="font-family:Calibri">1</span>所示<span style="font-family:Calibri">,</span>声明，本文所述的内容实乃<span style="font-family:Calibri">GNU</span>工具链的九牛之一毛,
 日后会陆续更新。</p>
<p align="left">&nbsp;<span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px">&nbsp;<a href="mailto:dyronchina@gmail.com" style="color: rgb(51, 102, 153); text-decoration: none;"><strong>http://blog.csdn.net/dyron</strong></a></span></p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 图1</p>
<div><strong><span style="font-size:18px"><span style="font-family:Cambria">2. </span>
工具链简介 </span></strong></div>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>下边就以列表的方式，对每一个工具链的作用进行介绍，在下一章进行实例演示。</p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-addr2line :</span></span></em></strong></p>
<p>把程序地址转换为文件名和行号。在命令行中给它一个地址和一个可执行文件名，</p>
<p>它就会使用这个可执行文件的调试信息指出在给出的地址上是哪个文件以及行号。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gcc:</span></span></em></strong></p>
<p><strong><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong>符合<span style="font-family:Calibri">ISO</span>标准的<span style="font-family:Calibri">C</span>编译器<span style="font-family:Calibri">,</span>这个大家都在用，不再赘述。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-objcopy:</span></span></em></strong></p>
<p><strong><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></strong>把一种目标文件中的内容复制到另一种类型的目标文件中。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-ar:</span></span></em></strong></p>
<p>建立、修改、提取归档文件。归档文件是包含多个文件内容的一个大文件，其结构</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>保证了可以恢复原始文件内容。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gcov:</span></span></em></strong></p>
<p><span style="font-family:Calibri">gcov</span>是一个保险测试工具。当构建一个程序时，<span style="font-family:Calibri">gcov</span>会监视一个程序的执行，并且会标识出执行了哪一行源码，哪一行没有执行。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-objdump:</span></span></em></strong></p>
<p>显示一个或者更多目标文件的信息。使用选项来控制其显示的信息。它所显示的信息通常只有编写编译工具的人才感兴趣。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-as:</span></span></em></strong></p>
<p>是<span style="font-family:Calibri"> GNU </span>汇编器，主要用来编译<span style="font-family:Calibri"> GNU C</span>编译器<span style="font-family:Calibri"> gcc</span>输出的汇编文件，它将汇编代码转换成二进制代码，并存放到一个<span style="font-family:Calibri">object</span>文件中，该目标文件将由连接器<span style="font-family:Calibri">
 ld</span>连接</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gdb:</span></span></em></strong></p>
<p><span style="font-family:Calibri">GNU</span>调试器。允许调试用<span style="font-family:Calibri">C\C++</span>和其他语言编写的应用程序。它的基本运行方式是在<span style="font-family:Calibri">shell</span>环境下用命令方式进行调试程序和显示数据。如果加上一些图形前端（如<span style="font-family:Calibri">DDD</span>等软件），则可以在一个更方便的图形环境下调试程序</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-ranlib:</span></span></em></strong></p>
<p>产生归档文件索引，并将其保存到这个归档文件中。在索引中列出了归档文件各成员所定义的可重分配目标文件。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-c++:</span></span></em></strong></p>
<p><strong><em><span style="font-family:Calibri; color:#4f81bd">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></em></strong>标准的<span style="font-family:Calibri">C++</span>编译器。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gdbtui:</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GDB</span>调试器的文本用户界面。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-readelf:</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示<span style="font-family:Calibri"> elf</span>格式可执行文件的信息</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-c++filt:</span></span></em></strong></p>
<p>解码<span style="font-family:Calibri"> C++ </span>符号名，连接器使用它来过滤<span style="font-family:Calibri"> C++</span>和<span style="font-family:Calibri"> Java</span>符号，防止重载函数冲突。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gprof:</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示程序调用段的各种数据<span style="font-family:Calibri">,</span>包括时间和次数等。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-size:</span></span></em></strong></p>
<p>列出目标文件每一段的大小以及总体的大小。默认情况下，对于每个目标文件或者一个归档文件中的每个模块只产生一行输出。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-cpp:</span></span></em></strong></p>
<p><span style="font-family:Calibri">GNU</span>预处理器，主要用于扩展用户源程序的头文件和宏定义。<span style="font-family:Calibri">cpp</span>是<span style="font-family:Calibri">GNU C</span>编译器的预处理器。<span style="font-family:Calibri">cpp</span>是一个宏指令处理器，<span style="font-family:Calibri">GNU
 C</span>编译器在编译前自动使用<span style="font-family:Calibri">cpp</span>对用户程序进行转换。<span style="font-family:Calibri">cpp</span>之所以被称为宏指令处理器是因为它允许用户定义宏指令（长结构的简写）。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-ld:</span></span></em></strong></p>
<p><span style="font-family:Calibri">GNU</span>链接器，主要用于确定相对地址，把多个<span style="font-family:Calibri">object</span>文件、起始代码段、库等链接起来，并最终形成一个可执行文件。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-strings:</span></span></em></strong></p>
<p>打印某个文件的可打印字符串，这些字符串最少<span style="font-family:Calibri"> 4 </span>个字符长，也可以使用选项<span style="font-family:Calibri"> -n</span>设置字符串的最小长度。默认情况下，它只打印目标文件初始化和可加载段中的可打印字符；对于其它类型的文件它打印整个文件的可打印字符，这个程序对于了解非文本文件的内容很有帮助。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-g++:</span></span></em></strong></p>
<p>基本符合<span style="font-family:Calibri">ISO</span>标准的<span style="font-family:Calibri">C++</span>编译器。</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-nm:</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>列出<span style="font-family:Calibri">object</span>文件中的符号</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-strip:</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>丢弃目标文件中的全部或者特定符号。</p>
<p>&nbsp;</p>
<div><span style="font-size:18px"><strong><span style="font-family:Cambria">3. </span>
工具使用举例<span style="font-family:Cambria">:</span> </strong></span></div>
<div>&nbsp;</div>
<p>&nbsp;&nbsp; 对于<span style="font-family:Calibri">GNU</span>工具链中的<span style="font-family:Calibri">GCC, G++, C++</span>等不再举例。</p>
<p><strong></strong>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">m</span></span><span style="color:#4f81bd"><span style="font-family:Calibri">ips-linux-gnu-ar:</span></span></em></strong></p>
<p><span style="font-family:Calibri">ar </span>用于建立、修改、提取归档文件，一个归档文件，是包含多个被包含文件的单个文件（也可以认为归档文件是一个库文件）。</p>
<p>被包含的原始文件的内容、权限、时间戳、所有者等属性都保存在归档文件中，并且在提取之后可以还原</p>
<p>&nbsp;</p>
<p>主要参数：</p>
<p><span style="font-family:Calibri">r - replace existing or insert new ﬁle(s) into the archive</span></p>
<p><span style="font-family:Calibri">v - be verbose</span></p>
<p>&nbsp;</p>
<p>生成归档文件的方法<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mips-linux-gnu-ar –rv libtest.a inputa.o inputb.o</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp; <strong><em><span style="color:#4f81bd">mips-linux-gnu-ranlib:</span></em></strong></span></p>
<p>这又是一个历史遗留问题，在早期版本中，<span style="font-family:Calibri">ar</span>只是将<span style="font-family:Calibri">.o</span>打包到<span style="font-family:Calibri">.a,</span>而不处理里边的符号表，<span style="font-family:Calibri">linker</span>需要一个完整的符号表，所以当时就单独写了一个<span style="font-family:Calibri">ranlib</span>来产生<span style="font-family:Calibri">linker</span>需要的符号表。后来产生完整符号表的功能被集成到<span style="font-family:Calibri">ar</span>中了，为了兼容，故<span style="font-family:Calibri">ranlib</span>还存在，总之以后尽量不要使用<span style="font-family:Calibri">ranlib</span>。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>生成完整符号表的方法<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Mips-linux-gnu-ranlib libtest.a</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp; <strong><em><span style="color:#4f81bd">mips-linux-gnu-nm:</span></em></strong></span></p>
<p><span style="font-family:Calibri">nm </span>的主要功能是列出目标文件中的符号，这样就可以定位和分析执行程序和目标文件中的符号信息和它的属性。</p>
<p>&nbsp;</p>
<p>生成符号前缀的含义<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">A</span>：符号的值是绝对值，并且不会被将来的链接所改变</p>
<p><span style="font-family:Calibri">B</span>：符号位于未初始化数据部分（<span style="font-family:Calibri">BSS</span>段）</p>
<p><span style="font-family:Calibri">C</span>：符号是公共的。公共符号是未初始化的数据。在链接时，多个公共符号可能以相同的名字出现。如果符号在其他地方被定义，则该文件中的这个符号会被当作引用来处理</p>
<p><span style="font-family:Calibri">D</span>：符号位于已初始化的数据部分</p>
<p><span style="font-family:Calibri">T</span>：符号位于代码部分</p>
<p><span style="font-family:Calibri">U</span>：符号未被定义？：符号类型未知，或者目标文件格式特殊</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>使用方法<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Mips-linux-gnu-nm –A libtest.a</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gcov:</span></span></em></strong></p>
<p>gcov会监视一个程序的执行，并且会标识出执行了哪一行源码，哪一行没有执行。更进一步，gcov可以标识出某一行源执行的次数，这对于执行配置很有用（程序在哪里花费了大多数的时间）</p>
<p>&nbsp;</p>
<p><strong>gcov的参数:</strong></p>
<p><span style="font-family:Calibri">-b,-branch-probabilities</span>向输出文件输出分支频度<br>
<span style="font-family:Calibri">-c,-branch-counts&nbsp;&nbsp; &nbsp;</span>打印分支计数而不是分支频度<br>
<span style="font-family:Calibri">-n,-no-output&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</span>不创建<span style="font-family:Calibri">gcov</span>输出文件<br>
<span style="font-family:Calibri">-l,-long-file-names&nbsp;&nbsp; &nbsp;</span>创建长文件名<br>
<span style="font-family:Calibri">-f,-function-summaries&nbsp;&nbsp; &nbsp;</span>打印每一个函数的概要<br>
<span style="font-family:Calibri">-o,-object-directory&nbsp;&nbsp; &nbsp;.bb,.bbg,.da</span>文件存放的目录</p>
<p>&nbsp;</p>
<p><strong><span style="font-family:Calibri">Gcov</span>实例<span style="font-family:Calibri">(</span>使用的<span style="font-family:Calibri">gcc</span>测试<span style="font-family:Calibri">):</span></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mips-linux-gnu-gcc a.c -o a -ftesage -fprofile-arcs</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 ./a 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>执行<span style="font-family:Calibri">a</span>文件<span style="font-family:Calibri">//</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mips-linux-gnu-gcov a.c //</span>会自动生成<span style="font-family:Calibri">a.c.gcov</span>文件</p>
<p><span style="font-family:Calibri">File 'a.c'</span></p>
<p><span style="font-family:Calibri">Lines executed:83.33% of 6</span></p>
<p><span style="font-family:Calibri">a.c:creating 'a.c.gcov'</span></p>
<p><span style="font-family:Calibri">vi a.c.gcov&nbsp; //</span>就可以看到代码的执行次数</p>
<p><span style="font-family:Calibri">mips-linux-gnu-gcov –b a.c&nbsp; //</span>可以查看<span style="font-family:Calibri">gcov</span>的分支执行频率</p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-c++filt:</span></span></em></strong></p>
<p>大家都知道在<span style="font-family:Calibri">C++</span>和<span style="font-family:Calibri">JAVA</span>中都有函数重载的机制，编译器在编译相同重载函数时，会使用<span style="font-family:Calibri">name mangling</span>机制对函数重新命名，而链接器连接的时候就需要对此进行解析。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">C++filt</span>常用参数<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">-_&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>滤掉符号前的下划线<br>
<span style="font-family:Calibri">&nbsp;&nbsp;&nbsp; -j&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>使用<span style="font-family:Calibri">Java</span>语法，默认为<span style="font-family:Calibri">C++<br>
&nbsp;&nbsp;&nbsp; -n&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>不要滤掉符号前的下划线<br>
<span style="font-family:Calibri">&nbsp;&nbsp;&nbsp; -p&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>不要打印函数的参数类型<br>
<span style="font-family:Calibri">&nbsp;&nbsp;&nbsp; -s&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span>指定解码方式，不同编译器的编码方式不同。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C++filt </span>使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-nm filt | 
grep func</span></p>
<p><span style="font-family:Calibri">080484d8 T _Z4funci</span></p>
<p><span style="font-family:Calibri">080484c4 T _Z4funcv</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-nm filt | grep func | mips-linux-gnu-c++filt</span></p>
<p><span style="font-family:Calibri">080484d8 T func(int)</span></p>
<p><span style="font-family:Calibri">080484c4 T func()</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-strip:</span></span></em></strong></p>
<p><span style="font-family:Calibri">strip</span>经常用来去除目标文件中的一些符号表、调试符号表信息，以减小程序的</p>
<p>大小，在<span style="font-family:Calibri">rpmbuild</span>包的最后就用到。</p>
<p>值得注意的是，在动态库和静态库时去掉符号表可以给文件瘦身，但再链接时可能编译不过去，所以<span style="font-family:Calibri">strip</span>慎用。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Strip</span>使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 dyron@harris-desktop:~/misc/module/test/tmp$ ls -l filt</span></p>
<p><span style="font-family:Calibri">-rwxr-xr-x 1 dyron dyron 7311 2011-08-31 10:29 filt</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-strip filt</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ ls -l filt</span></p>
<p><span style="font-family:Calibri">-rwxr-xr-x 1 dyron dyron 5552 2011-08-31 10:55 filt</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-gprof:</span></span></em></strong></p>
<p>打印出程序运行中各个函数消耗的时间，可以帮助程序员找出众多函数中耗时最多的函数。产生程序运行时候的函数调用关系，包括调用次数，可以帮助程序员分析程序的运行流程。</p>
<p><span style="font-family:Calibri">Gprof</span>的原理就是在加上<span style="font-family:Calibri">-pg</span>选项上，在编译和链接的时候，编译器在每个函数中都加入了一个名为<span style="font-family:Calibri">gcount</span>的函数，每个运行函数都会调用它，用来在内存中生成函数调用图。非常有用的一个工具，这里只是一个皮毛，等下次深入分析它的线程。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">Gporf</span>参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -p</span>得到每个函数占用的执行时间</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -q</span>得到<span style="font-family:Calibri">call graph</span>，包含了每个函数的调用关系，调用次数，执行时间等信息</p>
<p><span style="font-family:Calibri">-A</span>得到一个带注释的<span style="font-family:Calibri">“</span>源代码清单<span style="font-family:Calibri">”</span>，它会注释源码，指出每个函数的执行次数。这需要在编译的时候增加<span style="font-family:Calibri"> -g</span>选项。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Gprof</span>使用实例<span style="font-family:Calibri">:</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ gcc -pg a.c -o filt</span></p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ gprof -b filt gmon.out</span></p>
<p><span style="font-family:Calibri">Flat profile:</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">Each sample counts as 0.01 seconds.</span></p>
<p><span style="font-family:Calibri">&nbsp;no time accumulated</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp; %&nbsp;&nbsp; 
cumulative&nbsp;&nbsp; 
self&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 self &nbsp;&nbsp;&nbsp;&nbsp;total</span></p>
<p><span style="font-family:Calibri">&nbsp;time&nbsp;&nbsp; seconds&nbsp;&nbsp; seconds&nbsp;&nbsp;&nbsp; calls&nbsp; Ts/call&nbsp; Ts/call&nbsp; name</span></p>
<p><span style="font-family:Calibri">&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp; a</span></p>
<p><span style="font-family:Calibri">&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp; b</span></p>
<p><span style="font-family:Calibri">&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp;&nbsp; 0.00&nbsp; c</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Call graph</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">granularity: each sample hit covers 4 byte(s) no time propagated</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">index % time&nbsp;&nbsp;&nbsp; self&nbsp; children&nbsp;&nbsp;&nbsp; called&nbsp;&nbsp;&nbsp;&nbsp; name</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1/1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b [2]</span></p>
<p><span style="font-family:Calibri">[1]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0.0&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a [1]</span></p>
<p><span style="font-family:Calibri">-----------------------------------------------</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1/1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; main [7]</span></p>
<p><span style="font-family:Calibri">[2]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0.0&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b [2]</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1/1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c [3]</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1/1&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a [1]</span></p>
<p><span style="font-family:Calibri">-----------------------------------------------</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 0.00&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1/1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b [2]</span></p>
<p><span style="font-family:Calibri">[3]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
0.0&nbsp;&nbsp;&nbsp; 0.00&nbsp;&nbsp;&nbsp; 
0.00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c [3]</span></p>
<p><span style="font-family:Calibri">-----------------------------------------------</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">Index by function name</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp; [1] 
a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[2]
 
b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 [3] c</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-size :</span></span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示一个目标文件或者链接库文件中的目标文件的各个段的大小。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size</span>的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 -A –B: &nbsp;&nbsp;&nbsp;&nbsp; </span>
选择以<span style="font-family:Calibri">sysv|berkeley</span>的样式输出。</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 -o|-d|-x : </span>
选择输出数据的格式<span style="font-family:Calibri">. </span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 -t 
:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>选择全部输出。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size </span>的使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 [tulip]dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-size
 filt</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp; text&nbsp;&nbsp;&nbsp;
 data&nbsp;&nbsp;&nbsp;&nbsp; bss&nbsp;&nbsp;&nbsp;&nbsp; 
dec&nbsp;&nbsp;&nbsp;&nbsp; hex filename</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp; 
1477&nbsp;&nbsp;&nbsp;&nbsp; 280&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
12&nbsp;&nbsp;&nbsp; 1769&nbsp;&nbsp;&nbsp;&nbsp; 6e9 filt</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-as:</span></span></em></strong></p>
<p><span style="font-family:Calibri">GNU AS</span>是<span style="font-family:Calibri">GNU</span>汇编器，主要用于把汇编代码转换成二进制代码，并存放到一个<span style="font-family:Calibri">object</span>文件中。</p>
<p>大家都知道从源码到程序分为<span style="font-family:Calibri">4</span>个过程，<span style="font-family:Calibri">AS</span>做的工作就是第<span style="font-family:Calibri">3</span>步，将汇编指令码转换为二进制的文件。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">As </span>的使用实例<span style="font-family:Calibri">(</span>可用<span style="font-family:Calibri">gcc-c hello.s –o hello.o</span>代替<span style="font-family:Calibri">)</span>：</p>
<p><span style="font-family:Calibri">Mips-linux-gnu-as hello.s –o hello.o</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp; <strong><em><span style="color:#4f81bd">mips-linux-gnu-strings:</span></em></strong></span></p>
<p><span style="font-family:Calibri">strings</span>的功参简单，就是显示文件中的可打印字符，常用来在<a href="http://blog.chinaunix.net/link.php?url=http://os.51cto.com%2Fart%2F200709%2F56622.htm" target="_blank">二进制</a>文件中查找字符串。</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Strings</span>的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">-a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>不只是扫描目标文件初始化和装载段<span style="font-family:Calibri">,</span>而是扫描整个文件<span style="font-family:Calibri">.</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>在显示字符串之前先显示文件名<span style="font-family:Calibri">.</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -n min-len&nbsp;&nbsp;&nbsp;&nbsp; </span>打印至少<span style="font-family:Calibri">min-len</span>字符长的字符串<span style="font-family:Calibri">.</span>默认的是<span style="font-family:Calibri">4.</span></p>
<p><span style="font-family:Calibri">-t {o,x,d}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>在字符串前面显示其在文件中的偏移量<span style="font-family:Calibri">.</span>选项中的单个字符指定偏移量的进制是八进制<span style="font-family:Calibri">,</span>十六进制，还是十进制<span style="font-family:Calibri">.</span></p>
<p><span style="font-family:Calibri">--target=bfdname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>指定一种目标代码格式来代替你的系统的默认格式<span style="font-family:Calibri">.</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Strings </span>的使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">[tulip]dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-strings /usr/bin/uptime&nbsp; //</span>将会显示<span style="font-family:Calibri">uptime</span>中的字符串，默认是以<span style="font-family:Calibri">4</span>的最少长度。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp; <strong><em><span style="color:#4f81bd">mips-linux-gnu-objcopy:</span></em></strong></span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>可以将一种格式的目标文件内容进行转换，并输出为另一种格式的目标文件。</p>
<p>它使用<span style="font-family:Calibri"> GNU BFD(binary format description) </span>
库读<span style="font-family:Calibri"> / </span>写目标文件，通过这个<span style="font-family:Calibri"> BFD</span>库，<span style="font-family:Calibri">objcopy</span>能以一种不同于源目标文件的格式生成新的目标文件</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">Objcopy</span>命令的常用参数<span style="font-family:Calibri">(</span>太有用的命令了，参数一大堆<span style="font-family:Calibri">):</span></p>
<p><span style="font-family:Calibri">-I bfdname</span>或<span style="font-family:Calibri">—input-target=bfdname</span>用来指明源文件的格式<span style="font-family:Calibri">,bfdname</span>是<span style="font-family:Calibri">BFD</span>库中描述的标准格式名<span style="font-family:Calibri">,</span>如果没指明<span style="font-family:Calibri">,</span>则<span style="font-family:Calibri">objcopy</span>自己分析</p>
<p><span style="font-family:Calibri">-O bfdname&nbsp;</span>输出的格式</p>
<p><span style="font-family:Calibri">-F bfdname&nbsp;</span>同时指明源文件<span style="font-family:Calibri">,</span>目的文件的格式</p>
<p><span style="font-family:Calibri">-R sectionname&nbsp;</span>从输出文件中删除掉所有名为<span style="font-family:Calibri">sectionname</span>的段</p>
<p><span style="font-family:Calibri">-S&nbsp;</span>不从源文件中复制重定位信息和符号信息到目标文件中</p>
<p><span style="font-family:Calibri">-g&nbsp;</span>不从源文件中复制调试符号到目标文件中</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Objcopy </span>的使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">objcopy -I binary -O elf32-i386 -B i386 inputfile outputfile</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-readelf:</span></span></em></strong></p>
<p>显示一个或多个<span style="font-family:Calibri"> ELF </span>格式的目标文件信息。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Readelf</span>命令的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">-e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span>显示头信息，包括<span style="font-family:Calibri">ELF file header</span>、<span style="font-family:Calibri">section header</span>、<span style="font-family:Calibri">program header</span></p>
<p><span style="font-family:Calibri">-s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示符号表信息</p>
<p><span style="font-family:Calibri">-r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示重定位信息</p>
<p><span style="font-family:Calibri">-a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span>显示所有信息</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Readelf</span>的使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-readelf -h 
filt</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-readelf -e 
filt</span></p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/misc/module/test/tmp$ mips-linux-gnu-readelf -s filt</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-objdump</span>：</span></em></strong></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>显示一个或多个目标文件的信息，由其选项来控制显示哪些信息。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Objdump</span>的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>选项显示文件头的内容。</p>
<p><span style="font-family:Calibri">-d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>只反汇编代码段</p>
<p><span style="font-family:Calibri">-D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>反汇编代码段和数据段</p>
<p><span style="font-family:Calibri">-S&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>混合输出源代码和汇编代码，编译时必须加<span style="font-family:Calibri">-g</span>选项</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Objdump</span>的使用实例<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Mips-linux-gnu-objdump –f 
filt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</span>只显示<span style="font-family:Calibri">filt</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Mips-linux-gnu-objdump –d 
filt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</span>只反汇编代码段</p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-addr2line</span>：</span></em></strong><span style="font-family:Calibri">&nbsp;</span></p>
<p><span style="font-family:Calibri">Addr2line </span>工具（它是标准的<span style="font-family:Calibri"> GNU Binutils</span>中的一部分）是一个可以将指令的地址</p>
<p>和可执行镜象转换成文件名、函数名和源代码行数的工具。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr2line </span>的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
-e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span>选项来指定可执行映像是<span style="font-family:Calibri">&nbsp;test</span>。</p>
<p><span style="font-family:Calibri">&nbsp;-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>可以告诉工具输出函数名</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Addr2line </span>的使用实例<span style="font-family:Calibri">(android</span>分析<span style="font-family:Calibri">crash</span>错误<span style="font-family:Calibri">):</span></p>
<p>I/DEBUG&nbsp; &nbsp;( 3411):&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; #00&nbsp;&nbsp;pc 00000000&nbsp;&nbsp;<br>
I/DEBUG&nbsp; &nbsp;( 3411):&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
#01&nbsp;&nbsp;pc 000527e8&nbsp;&nbsp;/system/lib/libandroid_runtime.so<br>
I/DEBUG&nbsp; &nbsp;( 3411):&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 
#02&nbsp;&nbsp;pc 0000f1f4&nbsp;&nbsp;/system/lib/libdvm.so&nbsp;</p>
<p>这就是出问题时候的栈，<span style="font-family:Calibri">pc</span>等于<span style="font-family:Calibri">00000000</span>说明遇到了空指针，因为在栈里，所以查上一层指针<span style="font-family:Calibri">000527e8</span>，就可以分析到具体代码到哪一行了。</p>
<p><span style="font-family:Calibri">dyron@harris-desktop:~/project/test/android-2.2$
 mips-linux-gnu-addr2line&nbsp; -f -e 
out/target/product/tulip/symbols/system/lib/libandroid_runtime.so 
000527e8</span></p>
<p><span style="font-family:Calibri">??</span></p>
<p><span style="font-family:Calibri">/home/dyron/project/test/android-2.2/frameworks/base/core/jni/android_database_SQLiteDebug.cpp:129</span></p>
<p>&nbsp;</p>
<p><strong><em><span style="color:#4f81bd"><span style="font-family:Calibri">mips-linux-gnu-ld:&nbsp;&nbsp;&nbsp;</span></span></em></strong></p>
<p><span style="font-family:Calibri">ld</span>是<span style="font-family:Calibri">GNU binutils</span>工具集中的一个，是众多<span style="font-family:Calibri">Linkers</span>（链接器）的一种。完成的功能自然也就是链接器的基本功能：把各种目标文件和库文件链接起来，并重定向它们的数据，完成符号解析。<span style="font-family:Calibri">Linking</span>其实主要就是完成四个方面的工作：<span style="font-family:Calibri">storage
 allocation</span>、<span style="font-family:Calibri">symbol management</span>、<span style="font-family:Calibri">libraries</span>、<span style="font-family:Calibri">relocation</span>。</p>
<p><span style="font-family:Calibri">ld</span>可以识别一种<span style="font-family:Calibri">Linker command Language</span>表示的<span style="font-family:Calibri">linker scriopt</span>文件来显式的控制链接的过程。通过<span style="font-family:Calibri">BFD</span>（<span style="font-family:Calibri">Binary
 Format Description</span>）库，<span style="font-family:Calibri">ld</span>可以读取和操作<span style="font-family:Calibri">COFF</span>（<span style="font-family:Calibri">common object file format</span>）、<span style="font-family:Calibri">ELF</span>（<span style="font-family:Calibri">executable
 and linking format</span>）、<span style="font-family:Calibri">a.out</span>等各种格式的目标文件。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ld</span>的参数简介<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -b TARGET&nbsp; </span>设置目标文件的文件格式</p>
<p align="left"><span style="font-family:Calibri">-e ADDRESS </span>设置目标文件的开始地址</p>
<p align="left"><span style="font-family:Calibri">-EB&nbsp; </span>链接<span style="font-family:Calibri">big-endian</span>的目标文件</p>
<p align="left"><span style="font-family:Calibri">-EL&nbsp; </span>链接<span style="font-family:Calibri">small-endian</span>的目标文件</p>
<p align="left"><span style="font-family:Calibri">-l LIBNAME&nbsp;&nbsp;&nbsp; </span>创建执行程序时要链接的库文件（比如某个库为<span style="font-family:Calibri">test</span>，则可以为<span style="font-family:Calibri">-ltest</span>）</p>
<p align="left"><span style="font-family:Calibri">-L DIRECTORY&nbsp; </span>寻找要链接的库文件时搜索的文件路径</p>
<p align="left"><span style="font-family:Calibri">-o FILE&nbsp; </span>设置输出文件的名字</p>
<p align="left"><span style="font-family:Calibri">-s&nbsp; </span>去除输出文件中的所有符号信息</p>
<p align="left"><span style="font-family:Calibri">-S&nbsp; </span>去除输出文件中的调试符号信息</p>
<p align="left"><span style="font-family:Calibri">-T FILE&nbsp; </span>读取链接描述脚本，以确定符号等的定位地址</p>
<p align="left"><span style="font-family:Calibri">-v&nbsp; </span>输出<span style="font-family:Calibri">ld</span>的版本信息</p>
<p align="left"><span style="font-family:Calibri">-x&nbsp; </span>去除所有的局部符号信息</p>
<p align="left"><span style="font-family:Calibri">-X&nbsp; </span>去除临时的局部符号信息，默认情况下会设置这个选项</p>
<p align="left"><span style="font-family:Calibri">-Bstatic&nbsp;&nbsp; </span>创建的输出文件链接静态链接库</p>
<p align="left"><span style="font-family:Calibri">-Bdynamic&nbsp; </span>创建的输出文件链接动态链接库</p>
<p align="left"><span style="font-family:Calibri">-Tbss ADDRESS&nbsp; </span>设置<span style="font-family:Calibri">section bss</span>的起始地址</p>
<p align="left"><span style="font-family:Calibri">-Tdata ADDRESS </span>设置<span style="font-family:Calibri">section data</span>的起始地址</p>
<p align="left"><span style="font-family:Calibri">-Ttext ADDRESS </span>设置<span style="font-family:Calibri">section text</span>的起始地址</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ld</span>的例用实例</p>
<p>举个内核的例子<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">mips-linux-gnu-ld -T 
arch/mips/boot/compressed/ld.script -Ttext 0x80600000 -Bstatic -EL -o 
arch/mips/boot/compressed/vmlinuz arch/mips/boot/compressed/head.o 
arch/mips/boot/compressed/misc.o arch/mips/boot/compressed/piggy.o</span></p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ld.script</span>是链接脚本，<span style="font-family:Calibri">-o</span>是输出的文件名<span style="font-family:Calibri">, -Ttext</span>是设定<span style="font-family:Calibri">text</span>段的地址为<span style="font-family:Calibri">0x80600000,
 -EL</span>链接为小端文件。</p>
<p>&nbsp;</p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>再举个小例子，我们的程序开始过程<span style="font-family:Calibri">:</span></p>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 gcc -c 
a.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 //</span>编译成<span style="font-family:Calibri">.o</span>文件</p>
<p><span style="font-family:Calibri">ld -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o -lc a.o /usr/lib/crtn.o //</span>链接成<span style="font-family:Calibri">elf</span>可执行文件<span style="font-family:Calibri">.</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div><span style="font-size:18px"><strong><span style="font-family:Cambria">4. </span>
参考书籍<span style="font-family:Cambria">:</span> </strong></span></div>
<p><span style="font-family:Calibri">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>《程序员的自我修养》<span style="font-family:Calibri">------------------------------</span>俞甲子，石凡，潘爱民<span style="font-family:Calibri">.</span></p>
</div>

</div>
<div class="share_buttons" id="sharePanel"><span>分享到：</span> <a name="sina" class="share_sina" title="分享到新浪微博"></a><a name="qq" class="share_qq" title="分享到腾讯微博"></a></div>

<div class="article_next_prev">
        <li class="prev_article">
            <span>上一篇：</span><a href="http://blog.csdn.net/dyron/article/details/6866399">在使用svn的时候禁用svn保存密码功能</a></li>
        <li class="next_article">
            <span>下一篇：</span><a href="http://blog.csdn.net/dyron/article/details/6866685">选择排序的c实现代码</a></li>
</div>


        <div id="digg" articleid="6866406">
            <dl id="btnDigg" class="digg digg_enable">
                <dt>顶</dt>
                <dd>0</dd>
            </dl>
            <dl id="btnBury" class="digg digg_enable">
                <dt>踩</dt>
                <dd>0</dd>
            </dl>
        </div>
</div>
<div id="ad_cen"><iframe src="6866406_files/ad.htm" style="border-width: 0px; overflow: hidden; width: 732px; height: 92px;" id="ad_frm_0" frameborder="0" scrolling="no"></iframe></div>
<script type="text/javascript">
    new Ad(4, 'ad_cen');
</script>
<div id="comment_title" class="panel_head">查看评论<a name="comments"></a></div>
<div id="comment_list"><br>&nbsp;&nbsp;暂无评论<br><br><div class="clear"></div></div>
<div id="comment_bar"></div>
<div id="comment_form"><a name="commentbox"></a><a name="reply"></a><a name="quote"></a><form action="/dyron/comment/submit?id=6866406" method="post"><div class="commentform"><div class="panel_head">发表评论</div><ul><li class="left">用 户 名：</li><li class="right">fedorayang</li></ul><ul><li class="left">评论内容：</li><li class="right" style="position:relative;"><div id="ubbtools"><a href="#insertcode" code="code"><img src="6866406_files/code.gif" alt="插入代码" title="插入代码" border="0"></a></div><div id="lang_list" style="display:none; position:absolute;top:25px; left:0px;"><a href="#html">HTML/XML</a><a href="#javascript">JavaScript</a><a href="#css">CSS</a><a href="#php">PHP</a><a href="#csharp">C#</a><a href="#cpp">C++</a><a href="#java">Java</a><a href="#python">Python</a><a href="#ruby">Ruby</a><a href="#vb">Visual Basic</a><a href="#delphi">Delphi</a><a href="#sql">SQL</a><a href="#plain">其它</a></div><textarea class="comment_content" name="comment_content" id="comment_content" style="width: 400px; height: 200px;"></textarea></li></ul><ul><input id="comment_replyId" name="comment_replyId" type="hidden"><input id="comment_userId" name="comment_userId" value="521203" type="hidden"><input id="commentId" name="commentId" value="" type="hidden"><input class="comment_btn" value="提交" type="submit">&nbsp;&nbsp;<span id="tip_comment" style="color: Red; display: none;"></span></ul></div></form></div>
<div class="announce">* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
<script type="text/javascript">
    var fileName = '6866406';
    var commentscount = 0;
    var islock = false
</script>
<script type="text/javascript" src="6866406_files/comment.js"></script>
<div id="ad_bot"><iframe src="6866406_files/ad_002.htm" style="border-width: 0px; overflow: hidden; width: 732px; height: 170px;" id="ad_frm_1" frameborder="0" scrolling="no"></iframe></div>
<script type="text/javascript">
    new Ad(5, 'ad_bot');
</script>
<div id="report_dialog"></div>


<div class="clear"></div>
</div>
</div>
<div id="side">
    <div class="side">
<div id="panel_Profile" class="panel">
    <ul class="panel_head"><span>个人资料</span></ul>
    <ul class="panel_body profile">
        <div id="blog_userface">
            <a href="http://my.csdn.net/dyron" target="_blank">
            <img src="6866406_files/1_dyron.jpg" title="访问我的空间" style="max-width: 90%;">
            </a>
            <br>
            <span><a href="http://my.csdn.net/dyron" target="_blank">dyron</a></span>
        </div>
<div class="interact">
<!--<a href="#" class="attented" title="已关注"></a>-->
<a href="#" class="attent" id="span_add_follow" title="[加关注]"></a>
<a href="http://my.csdn.net/my/letter/send/dyron" class="letter" title="[发私信]"></a>
</div>
        <div id="blog_medal">
        </div>
        <ul id="blog_rank">
            <li>访问：<span>4569次</span></li>
            <li>积分：<span>276分</span></li>
            <li>排名：<span>千里之外</span></li>
        </ul>
        <ul id="blog_statistics">
            <li>原创：<span>24篇</span></li>
            <li>转载：<span>3篇</span></li>
            <li>译文：<span>0篇</span></li>
            <li>评论：<span>6条</span></li>
        </ul>
    </ul>
</div>

<script type="text/javascript">
var _blogger='dyron';
$(document).ready(function () {
    $('#span_add_follow').click(function () {
        var url = "http://my.csdn.net/index.php/follow/do_follow?jsonpcallback=?";
        $.getJSON(url, { "username": _blogger }, function (data) {
            if (data.succ == 1) {
                alert('关注成功！');
                $('#span_add_follow').attr('class', 'attented').click(function () { return false; });
            } else {
                alert(data.msg);
            }
        });
    });
    if (getUN().toLowerCase() == _blogger.toLowerCase()) {
        $('.interact').hide();
    }
});
function getUN() {
    var m = document.cookie.match(new RegExp("(^| )UserName=([^;]*)(;|$)"));
    if (m) return m[2];
    else return '';
}
</script>

<div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body">
        <form id="frmSearch" action="http://so.csdn.net/search" class="form_search" target="_blank">
        <span><input id="inputSearch" class="blogsearch" title="请输入关键字" type="text"></span>
        <input id="btnSubmit" value="搜索" title="search in blog" type="submit">
        <input name="q" id="inputQ" type="hidden">
        <input name="t" value="blog" type="hidden">
        <a id="btnSearchBlog" target="_blank"></a>
        </form>
    </ul>
</div><div id="panel_Category" class="panel">
    <ul class="panel_head"><span>文章分类</span></ul>
    <ul class="panel_body">
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904108">wireless</a><span>(2)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904105">toolchain</a><span>(1)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904115">环境配置</a><span>(3)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904101">kernel</a><span>(6)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904102">audio(oss&amp;alsa)</a><span>(4)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904103">framebuff(lcd&amp;epd)</a><span>(3)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904104">touchscreen</a><span>(0)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904121">python&amp;shell</a><span>(3)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/904129">C与算法</a><span>(6)</span>
        
        </li>
        <li>
        <a href="http://blog.csdn.net/dyron/article/category/905922">bootloader</a><span>(1)</span>
        
        </li>
    </ul>
</div><div id="panel_Archive" class="panel">
    <ul class="panel_head"><span>文章存档</span></ul>
    <ul class="panel_body">
        <div id="archive_list">
        <!--归档统计-->
        <li><a href="http://blog.csdn.net/dyron/article/month/2012/02">2012年02月</a>(1)</li><li><a href="http://blog.csdn.net/dyron/article/month/2011/12">2011年12月</a>(4)</li><li><a href="http://blog.csdn.net/dyron/article/month/2011/11">2011年11月</a>(4)</li><li><a href="http://blog.csdn.net/dyron/article/month/2011/10">2011年10月</a>(18)</li>
        </div>
    </ul>
</div>
<div id="hotarticls" class="panel">
    <ul class="panel_head"><span>阅读排行</span></ul>
    <ul class="panel_body">
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866406" title="GNU工具链简介（全）">GNU工具链简介（全）</a> (381)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6872854" title="bootloader(xboot)起动流程分析">bootloader(xboot)起动流...</a> (365)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6947969" title="wifi批量安装及自动化测试脚本">wifi批量安装及自动化测试脚本</a> (248)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866395" title="君正4760B的linux audio(OSS)驱动分析">君正4760B的linux audio(...</a> (247)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6874290" title="Linux audio(OSS)子系统分析">Linux audio(OSS)子系统分...</a> (205)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866392" title="linux audio(alsa) 驱动注册的简明流程.">linux audio(alsa) 驱动...</a> (192)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6870292" title="linux+audio(OSS)驱动的读写buff分析(jz4760B)">linux+audio(OSS)驱动的读...</a> (182)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/7064074" title="LinuxI2C总线驱动深入分析">LinuxI2C总线驱动深入分析</a> (179)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866348" title="Ethereal过滤规则语法">Ethereal过滤规则语法</a> (162)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866372" title="linux内核层与应用层通讯方法">linux内核层与应用层通讯方法</a> (103)
        </li>
    </ul>
</div>
<div id="hotarticls" class="panel">
    <ul class="panel_head"><span>评论排行</span></ul>
    <ul class="panel_body">
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6872854" title="bootloader(xboot)起动流程分析">bootloader(xboot)起动流...</a> (4)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6866685" title="选择排序的c实现代码">选择排序的c实现代码</a> (2)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6870292" title="linux+audio(OSS)驱动的读写buff分析(jz4760B)">linux+audio(OSS)驱动的读...</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6874290" title="Linux audio(OSS)子系统分析">Linux audio(OSS)子系统分...</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6947969" title="wifi批量安装及自动化测试脚本">wifi批量安装及自动化测试脚本</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6952042" title="关于无名结构体的见解">关于无名结构体的见解</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6953291" title="简化版udev,抓取uevent信息">简化版udev,抓取uevent信息</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/6981476" title="电流的产生和电能的转换">电流的产生和电能的转换</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/7049460" title="EXT3与EXT4的主要区别">EXT3与EXT4的主要区别</a> (0)
        </li>
        <li>
            <a href="http://blog.csdn.net/dyron/article/details/7056611" title="驱动程序中的时间消耗计算">驱动程序中的时间消耗计算</a> (0)
        </li>
    </ul>
</div>
<div id="homepageArticles" class="panel">
    <ul class="panel_head"><span>推荐文章</span></ul>
    <ul class="panel_body" id="ad_commend"><iframe src="6866406_files/ad_003.htm" style="border-width: 0px; overflow: hidden; width: 182px; height: 254px;" id="ad_frm_2" frameborder="0" scrolling="no"></iframe></ul>
</div>
<script type="text/javascript" src="6866406_files/ad.js"></script>
<script type="text/javascript">
    new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body">
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6872854#comments">bootloader(xboot)起动流程分析</a>
    <p style="margin:0px;">dyron:
@dukedz:看Changelog与README应该是君正人完成的。
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6872854#comments">bootloader(xboot)起动流程分析</a>
    <p style="margin:0px;">dukedz:
xboot 是君正人寫的嗎？
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6872854#comments">bootloader(xboot)起动流程分析</a>
    <p style="margin:0px;">dyron:
无味咖啡: 君正Ftp公开的uboot不支持emmc启动xboot和uboot相差很大吗MID的刷机...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6872854#comments">bootloader(xboot)起动流程分析</a>
    <p style="margin:0px;">dyron:
在xboot中增加关机的充电画面，主要逻辑如下:       开机-----&gt; 是否正常开机---Y...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6866685#comments">选择排序的c实现代码</a>
    <p style="margin:0px;">dyron:
@qianjin0703:哪有，我一直在其它地方开博客的，整理了一下，发现自己写的文章太少太少了，昨...
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6866685#comments">选择排序的c实现代码</a>
    <p style="margin:0px;">qianjin0703:
狄总，你一天博文的数量赶上我写一年的了。。顶啊，c语言很重要，看来还是要从基础抓起！
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6866329#comments">%e9%80%89%e6%8b%a9%e6%8e%92%e5%ba%8f%e7%9a%84c%e5%ae%9e%e7%8e%b0%e4%bb%a3%e7%a0%81</a>
    <p style="margin:0px;">dyron:
@C201008:哪有哪有，很久前写的code，记录在这里。 欢迎讨论
    </p>
    </li>
    <li>
    <a href="http://blog.csdn.net/dyron/article/details/6866329#comments">%e9%80%89%e6%8b%a9%e6%8e%92%e5%ba%8f%e7%9a%84c%e5%ae%9e%e7%8e%b0%e4%bb%a3%e7%a0%81</a>
    <p style="margin:0px;">C201008:
LZ V5
    </p>
    </li>
</ul>
</div>
    </div>
    <div class="clear">
    </div>
</div>

<div class="clear"></div>
</div>
<script type="text/javascript" src="6866406_files/shCore-src.js"></script>
<script type="text/javascript" src="6866406_files/ZeroClipboard.js"></script>
<script type="text/javascript" src="6866406_files/article_code.js"></script>

<script type="text/javascript" src="6866406_files/show.js"></script>
<script type="text/javascript" src="6866406_files/showblogmedal.htm"></script>
<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script><img src="6866406_files/pv.xml" border="0" height="0" width="0">
<script type="text/javascript" src="6866406_files/publib_footer.js"></script><link rel="stylesheet" type="text/css" href="6866406_files/pub_footer_2012.css"><div class="pub_footerall"><dl><dt></dt> <dd><a href="http://www.csdn.net/company/about.html" target="_blank">公司简介</a>|<a href="http://www.csdn.net/company/recruit.html" target="_blank">招贤纳士</a>|<a href="http://www.csdn.net/company/marketing.html" target="_blank">广告服务</a>|<a href="http://www.csdn.net/company/account.html" target="_blank">银行汇款帐号</a>|<a href="http://www.csdn.net/company/contact.html" target="_blank">联系方式</a>|<a href="http://www.csdn.net/company/statement.html" target="_blank">版权声明</a>|<a href="http://www.csdn.net/company/layer.html" target="_blank">法律顾问</a>|<a href="mailto:webmaster@csdn.net">问题报告</a></dd><dd>京&nbsp;ICP&nbsp;证&nbsp;070598&nbsp;号</dd><dd>北京创新乐知信息技术有限公司 版权所有</dd><dd><img src="6866406_files/ico_email.gif" alt="" title=""> 联系邮箱：webmaster@csdn.net</dd><dd>Copyright © 1999-2012, CSDN.NET, All Rights Reserved&nbsp;<a href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010" target="_blank"><img src="6866406_files/gongshang_logos.gif" alt="GongshangLogo" title=""></a></dd></dl></div>




</div>

</body></html>